package com.wanxi.innerclass;

public class Test {
    public void walk() {
        OutClass outClass = new OutClass();
        outClass.run();
//        outClass.new InnerClass().sleep();
        OutClass.InnerClass innerClass = outClass.new InnerClass();
        innerClass.sleep();
    }

    public static void main(String[] args) {
////        匿名内部类
//        IAnimal iAnimal = new IAnimal() {
//            @Override
//            public void run() {
//
//            }
//        };
////        IAnimal dog=new Dog();
//        Animal animal = new Animal() {
//            @Override
//            public void run() {
//
//            }
//        };
        Animal animal = new Dog();
        Dog dog = (Dog) animal;
        if (dog instanceof Animal) {
            System.out.println(1);
        } else {
            System.out.println(2);
        }

        if (animal instanceof Cat) {
            Cat cat = (Cat) animal;
            System.out.println(3);
        } else {
            System.out.println(4);
        }
        try {

        }catch (Exception e){

        }
        finally {

        }
    }
}
